package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.util.ApplicablePlatformEnum;
import com.frogs.system.util.ExpandCodeEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 积分兑换卡券请求参数
 * 
 * @author DLM
 *
 */
public class IntegralExchangeCouponRequest extends Request {

	private static final long serialVersionUID = 1630639580425503706L;
	
	/**
	 * 用户ID
	 */
	private Integer userId;
	
	/**
	 * 兑换对照表id
	 */
	private Integer id;
	
	/**
	 * 渠道
	 */
	private String expandCode;
	
	/**
	 * 平台
	 */
	private Integer applicablePlatformId;

	@Override
	public void parse(HttpServletRequest request) {
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.id = requestInfo.getIntParameter(ApiUrlParamEnum.id.getParamName(), 0);
		this.expandCode = requestInfo.getParameter(ApiUrlParamEnum.expandCode.getParamName(), ExpandCodeEnum.MALL.getId());
		this.applicablePlatformId = requestInfo.getIntParameter(ApiUrlParamEnum.applicablePlatformId.getParamName(), ApplicablePlatformEnum.WEB.getId());
		
		if (userId < 1) {
			throw new RequestIllegalException("error userId: " + userId);
		}
		if (id < 1) {
			throw new RequestIllegalException("error id: " + id);
		}

	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getExpandCode() {
		return expandCode;
	}

	public void setExpandCode(String expandCode) {
		this.expandCode = expandCode;
	}

	public Integer getApplicablePlatformId() {
		return applicablePlatformId;
	}

	public void setApplicablePlatformId(Integer applicablePlatformId) {
		this.applicablePlatformId = applicablePlatformId;
	}

}
